package com.google.common.collect;

final class Hashing {
    static int MAX_TABLE_SIZE = 1073741824;

    static int smear(int hashCode) {
        return 461845907 * Integer.rotateLeft(-862048943 * hashCode, 15);
    }

    static int closedTableSize(int expectedEntries, double loadFactor) {
        expectedEntries = Math.max(expectedEntries, 2);
        int tableSize = Integer.highestOneBit(expectedEntries);
        if (((double) expectedEntries) / ((double) tableSize) <= loadFactor) {
            return tableSize;
        }
        tableSize <<= 1;
        return tableSize > 0 ? tableSize : MAX_TABLE_SIZE;
    }
}
